<template>
  <div class="wrap">
    <header>
      <span @click="go()">&lt;</span>
      <p>卖房成交战绩</p>
    </header>
    <main>
      <div class="ji1">
        <div class="search">
          <p @click="tocity" class="citysize">{{city}}</p>
          <div class="input">
            <input type="text" placeholder="请在这里输入区域/商圈" v-model="val" @input="search" />
            <van-icon name="search" />
          </div>
          <span @click="toji1()">租房成交战绩</span>
        </div>
        <div class="getList">
          <div v-for="(item,idx) in list" :key="idx" class="home">
            <img :src="item.img" alt />
            <div class="font">
              <h4>{{item.title}}</h4>
              <p class="p">43平/2室 1厅/远洋新天地</p>
              <div class="fonts">
                <span>{{item.price}}万</span>
                <p>12100元/m²</p>
              </div>
              <div class="font1">
                <p class="style">{{item.type}}</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      list: [],
      val: ""
    };
  },
  created() {
    this.getList();
    this.city = localStorage.getItem("city") || "北京";
  },
  methods: {
    go() {
      this.$router.go(-1);
    },
    tocity() {
      this.$router.push("/city");
    },
    async getList() {
      const res = await axios.post("/api/search", { val: this.val });
      // console.log(res);
      this.list = res.data.data;
      // axios({
      //   url: "/api/getList",
      //   method: "post"
      // }).then(res => {
      //   // console.log(res);
      //   this.list = res.data.data;
      // });
    },

    search() {
      this.getList();
    },

    toji1() {
      this.$router.push("/ji1");
    }
  }
};
</script>

<style lang="scss" scoped>
.wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
header {
  width: 100%;
  height: 50px;
  display: flex;
  line-height: 50px;
  align-items: center;
  background: rgb(56, 121, 240);
  padding: 15px;
  color: #fff;
  p {
    padding-left: 38%;
  }
}
main {
  flex: 1;
  overflow-y: scroll;
  .ji1 {
    .search {
      width: 90%;
      height: 40px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin: 5% 15px;
      .citysize {
        font-size: 15px;
        color: #333;
      }
      .input {
        height: 30px;
        width: 200px;
        background: #f1f1f1;
        input {
          background: #f1f1f1;
          border: none;
          font-size: 14px;
          padding-left: 6px;
        }
        display: flex;
        align-items: center;
      }
      span {
        font-size: 15px;
      }
    }
  }
  .getList {
    width: 100%;
    // height: 650px;
    // overflow: hidden;
    .home {
      display: flex;
      margin: 10px 0;
      padding: 10px;
      img {
        width: 120px;
        height: 80px;
      }
      .font {
        padding-left: 10px;
        align-items: center;
        .p {
          font-size: 14px;
        }
        .fonts {
          display: flex;
          align-items: center;

          span {
            color: rgb(247, 136, 25);
            font-size: 14px;
          }
          p {
            padding-left: 8px;
            font-size: 14px;
          }
        }
        .font1 {
          display: flex;
          align-items: center;
          .style {
            width: 50px;
            height: 22px;
            background: #ccc;
            font-size: 14px;
            margin-right: 8px;
          }
          p {
            font-size: 16px;
            padding: 0 4px;
          }
        }
      }
    }
  }
}
</style>